﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="AjaxDemos_Default" %>

<%@ Register assembly="Org.Eurekaa.DNJ" namespace="Org.Eurekaa.DNJ.WebControls" tagprefix="dnj" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>DNJ Demo page</title>
    <link href="../css/nyroModal.full.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #target
    {
        border:2px solid #0a0;
        display:block;
        width:300px;
        height:200px;
    }
    .dnj-indicator
    {
        border:0px;
        background: #a00;
        color:#fff;
        position:absolute;
        top:0px;
        right:0px;
        width:150px;
        font:700 11px verdana;
        padding:2px 5px;
    }
    
    </style>
    
    <!-- Use the DNJResources axd to load jquery-->
	<script type="text/javascript" src="DNJResources.axd?load=jquery"></script>
	<script type="text/javascript" src="../js/jquery.nyroModal-1.5.0.min.js"></script>		
	
	<!-- Use the DNJResources axd to generate RPC scripts-->
	<script type="text/javascript" src="DNJResources.axd?conf=../dnj/config/jsonmap.js"></script>
	
	<script type="text/javascript">   
	// JSON RPC bindings
    function showResult(data)
    {
        $('#target').html('<b>JSON Response : </b><br /><b>result</b> : ' + data.result + ' ; <b>errors</b> : '+data.error + ' ; <b>id</b> : '+data.id);
    }
    
     $(document).ready(function(){

       $('#Button1').bind('click', function(){
		    $.DNJRPC({success:showResult}).App_Code.includes.SayHello();
       });
       $('#Button2').bind('click', function(){
		    $.DNJRPC('#target').App_Code.includes.Say($('#str').val());

       });
       $('#Button3').bind('click', function(){
            $.DNJRPC('#result').App_Code.includes.Add($('#va').val() , $('#vb').val());
       });
       $('#Button4').bind('click', function(){
            $.DNJRPC({success:showResult}).package.BLProcess();
       });
    
                   
     });
    

	</script>    
	<script type="text/javascript">   
        $(document).ready(function() {    
        
        //Creating a custom ajax indicator (this will mimic the GMail "loading" indicator)
        var indicator = $('<div>Loading</div>').addClass('dnj-indicator').hide();
        $('body').append(indicator);
        $(window).scroll(function() {
            indicator.css('top', $(this).scrollTop() + "px");
        });                                         


	    // Custom DNJ ajaxifier initialisation
	    // Note that we can activate DNJ by simple $.DNJ() call
	    // The example bellow shows how we can add some visual effects for loading, waiting, errors ...etc
	    //       
	     
        $.DNJ({
            errorCallBack : function(msg) {
                    $.nyroModalManual({
                      bgColor: '#ffaaaa',
                      title: 'An error has occured',
                      content: msg
                    });            
                }, 
            beforeCallBack : function(sender)
                {
                    indicator.show();
                    //sender.fadeTo("fast", 0.50);
                }, 
            afterCallBack : function(sender)
                {
                    indicator.hide();
                    //sender.fadeTo("fast", 1.00);                    
                }
        }); 
        
   });     
	</script>        
	
    
	
</head>
<body>
    <form id="form1" runat="server">
        <table style="width:100%;">
            <tr>
                <td>
                    <b>Some RPC examples</b><br />
                    Call BLProcess() from external dll (process.dll)<br />
                    <input id="Button4" type="button" value="BLProcess"/>
                    <br />
                    <br />
                    Call SayHello() from App_Code<br />
                    <input id="Button1" type="button" value="SayHello"/>
                    <br />
                    <br />
                    Call Say(string something) from App_Code<br />
                    <input id="str" type="text" value="Eurekaa!" /><input id="Button2" type="button" value="Say"/>
                    <br />
                    <br />
                    Call Add(int a, int b)&nbsp; or Add(float a, float b) depending on entered parameters
                    from App_Code<br />
                    <input id="va" style="width: 27px" type="text" value="5" />
                    +
                    <input id="vb" style="width: 31px" type="text" value="56" />
                    <input id="Button3" type="button" value="Add"/>
                    <input id="result" style="width: 60px" type="text" value="" />
                    <br />
                </td>
                <td>
                    <b>Simple example of ajaxified content</b><br />
                    bellow some standard asp.net controls, ajaxified simply by putting them inside a DNJPanel
                    <dnj:DNJPanel ID="DNJPanel1" runat="server" BackColor="#F3F3F3" 
                        BorderColor="Black" BorderStyle="Dashed">
                        <h3>Standard Calendar control</h3><asp:Calendar ID="Calendar1" runat="server" 
                            BackColor="#FFFFCC" BorderColor="#FFCC66" BorderWidth="1px" 
                            DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
                            ForeColor="#663399" Height="200px" ShowGridLines="True" Width="220px">
                            <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
                            <SelectorStyle BackColor="#FFCC66" />
                            <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
                            <OtherMonthDayStyle ForeColor="#CC9966" />
                            <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
                            <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
                            <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" 
                                ForeColor="#FFFFCC" />
                        </asp:Calendar>
                        <h3>Read date from calendar control</h3>
                        &nbsp;<asp:Button ID="Button5" runat="server" OnClick="Button5_Click" 
                                Text="Get Date" />
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <br />
                        <br />
                        <h3>Copy source text to target after a thread.sleep of two seconds</h3>
                        <asp:TextBox ID="TxtSource" runat="server">Source</asp:TextBox>
                        <asp:Button ID="BtnCopy" runat="server" onclick="BtnCopy_Click" 
                            Text="Copy with delay" />
                        <asp:TextBox ID="TxtTarget" runat="server">Target</asp:TextBox>
                        <br />
                        <h3>Exception example</h3>&nbsp;
                            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Throw 
                        exception example</asp:LinkButton>
                        &nbsp;(use nyromodal plugin to show the error).<br />
                        <br />
                    </dnj:DNJPanel>
            
                    
                </td>
            </tr>
            <tr>
                
                <td>
                    <b>Target for all remote calls</b>
                    <div id="target"></div>                    
                </td>
                <td>
                    
                </td>
            </tr>
        </table>
        </form>

</body>
</html>
